home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume90
/
comm
/
dnet
/
dnet_213
/
part05
< prev
next >
Wrap
Text File
|
1990-03-27
|
58KB
|
2,656 lines
Path: xanth!cs.odu.edu!Amiga-Request
From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
Newsgroups: comp.sources.amiga
Subject: v90i122: DNet 2.13 - multiple windows/file transfers over a serial line, Part05/08
Message-ID: <11942@xanth.cs.odu.edu>
Date: 27 Mar 90 01:21:43 GMT
Sender: tadguy@cs.odu.edu
Reply-To: dales%teksce.sce.tek.com@RELAY.CS.NET
Lines: 2642
Approved: tadguy@cs.odu.edu (Tad Guy)
X-Mail-Submissions-To: Amiga@cs.odu.edu
X-Post-Discussions-To: comp.sys.amiga
Submitted-by: dales%teksce.sce.tek.com@RELAY.CS.NET
Posting-number: Volume 90, Issue 122
Archive-name: comm/dnet/dnet-2.13/part05
#!/bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 5 (of 8)."
# Contents: amiga/client/cliterm.c amiga/client/fterm.c
# amiga/client/getfiles.c amiga/dnet/sernet.c amiga/server/sgcopy.c
# unix/dnet/subs.c
# Wrapped by tadguy@xanth on Mon Mar 26 20:15:18 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'amiga/client/cliterm.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/client/cliterm.c'\"
else
echo shar: Extracting \"'amiga/client/cliterm.c'\" \(7824 characters\)
sed "s/^X//" >'amiga/client/cliterm.c' <<'END_OF_FILE'
X
X/*
X * CLITERM.C
X *
X * DNET (c)Copyright 1988-1989, Matthew Dillon, All Rights Reserved.
X *
X * FTERM [-Nnet] [port]
X */
X
X#include "defs.h"
X
Xtypedef struct IORequest RIO;
X
X
X#ifndef DEVICES_CONUNIT_H
Xtypedef struct ConUnit CONUNIT;
Xtypedef struct IOStdReq IOCON;
X#endif
X
Xshort IgnoreNS = 0;
X
XTA Ta = { (ubyte *)"topaz", 8 };
X
XITEXT IText[] = {
X { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"Flush" }
X};
X
XITEM Item[] = {
X { NULL , 0, 0, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[0], NULL, 'o' }
X};
X
XMENU Menu[] = {
X { NULL , 0, 0, 100, 20, MENUENABLED, "Control", &Item[0] }
X};
X
Xchar Title[80];
X
XNW Nw = {
X 0, 12, 640, 60, -1, -1,
X NEWSIZE|CLOSEWINDOW|MENUPICK,
X WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH|ACTIVATE,
X NULL, NULL, (ubyte *)Title, NULL, NULL,
X 32, 32, -1, -1, WBENCHSCREEN
X};
X
XWIN *Win;
X
Xextern int Enable_Abort;
Xchar Buf[512];
Xchar Term[64] = { "FTERM (UNNAMED SHELL)" };
Xchar Cc;
X
Xstruct IntuitionBase *IntuitionBase;
Xstruct GfxBase *GfxBase;
XIOCON *iocr, *iocw;
X
Xvoid OpenConsole ARGS((WIN *, IOCON **, IOCON **));
Xvoid HandleIoctl ARGS((short, short, char, WIN *, IOCON *));
Xvoid CloseConsole ARGS((IOCON *, IOCON *));
Xvoid setsize ARGS((IOCON *, void *, WIN *));
Xvoid localecho ARGS((int));
X
Xvoid main ARGS((int, char **));
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
Xmain(ac,av)
Xchar *av[];
X{
X void *chan;
X long imask, conmask, dmask, mask;
X char notdone = 1;
X char portspec = 0;
X char *host = NULL;
X uword port = PORT_AMIGASHELL;
X int i;
X int bp = 0;
X char inputbuf[256];
X
X onbreak(brk);
X sprintf(Title, "CLITerm V%s%s opening, wait..", VERSION, CLITERM_VERSION);
X {
X short i;
X for (i = 1; i < ac; ++i) {
X if (strncmp(av[i], "-N", 2) == 0) {
X host = av[i] + 2;
X continue;
X }
X portspec = 1;
X port = atoi(av[i]);
X }
X }
X if (portspec)
X printf("Using port %ld\n", port);
X#ifndef LATTICE
X Enable_Abort = 0;
X#endif
X IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
X GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);
X Win = OpenWindow(&Nw);
X if (Win == NULL)
X goto e1;
X OpenConsole(Win, &iocr, &iocw);
X if (iocr == NULL || iocw == NULL)
X goto e3;
X
X /*
X * We delay here to allow DNET to go through its RESTART sequence
X * (when DNET automatically runs FTERM, it does so to quickly).
X * Such a hack!
X */
X
X Delay(50 * 4);
X chan = DOpen(host, port, 20, 15);
X
X if (!chan) {
X puts("Unable to connect");
X goto e3;
X }
X DQueue(chan, 32);
X SetMenuStrip(Win, Menu);
X SetWindowTitles(Win, Term, (char *)-1);
X imask = 1 << Win->UserPort->mp_SigBit;
X dmask = 1 << ((PORT *)chan)->mp_SigBit;
X conmask = 1 << iocr->io_Message.mn_ReplyPort->mp_SigBit;
X iocr->io_Data = (APTR)&Cc;
X iocr->io_Length = 1;
X SendIO((RIO *)iocr);
X
X setsize(iocw, chan, Win);
X
X while (notdone) {
X mask = Wait(imask|dmask|conmask);
X if (mask & imask) {
X IMESS *im;
X while (im = (IMESS *)GetMsg(Win->UserPort)) {
X switch(im->Class) {
X case NEWSIZE:
X if (IgnoreNS) {
X --IgnoreNS;
X setsize(iocw, NULL, Win);
X } else {
X setsize(iocw, chan, Win);
X }
X break;
X case CLOSEWINDOW:
X notdone = 0;
X break;
X case MENUPICK:
X switch((uword)((MENUNUM(im->Code)<<8)|ITEMNUM(im->Code))) {
X case 0x0000: /* menu 0 item 0 */
X DIoctl(chan, CIO_FLUSH, 0, 0);
X break;
X case 0x0001: /* menu 0 item 1 */
X case 0x0002: /* menu 0 item 2 */
X case 0x0100: /* menu 1 item 0 */
X break;
X }
X break;
X default:
X break;
X }
X ReplyMsg((MSG *)im);
X }
X }
X if (mask & dmask) {
X char buf[256];
X int n;
X if ((n = DNRead(chan, buf, 256)) > 0) {
X for (i = 0; i < n; i++) {
X if (buf[i] == '\n') {
X movmem(&buf[i], &buf[i + 1], n - i);
X buf[i] = '\r';
X i++;
X n++;
X }
X }
X iocw->io_Data = (APTR)buf;
X iocw->io_Length = n;
X DoIO((RIO *)iocw);
X }
X if (n == -2) {
X short val;
X short cmd;
X char aux;
X
X cmd = DGetIoctl(chan, &val, &aux);
X HandleIoctl(cmd, val, aux, Win, iocw);
X /*
X if (cmd == CIO_MODE) {
X if (val)
X SetWindowTitles(Win, "(Cooked)", (char *)-1);
X else
X SetWindowTitles(Win, "(Raw)", (char *)-1);
X }
X */
X } else if (n < 0)
X notdone = 0;
X }
X if (mask & conmask) {
X if (CheckIO((RIO *)iocr)) {
X WaitIO((RIO *)iocr);
X
X if (Cc == '\r')
X Cc = '\n';
X inputbuf[bp++] = Cc;
X
X if (Cc == 0x08) {
X if (bp <= 1) {
X bp = 0;
X } else {
X localecho(0x08);
X localecho(0x20);
X localecho(0x08);
X bp -= 2;
X }
X } else if (Cc == 0x18) {
X while (--bp > 0) {
X localecho(0x08);
X localecho(0x20);
X localecho(0x08);
X }
X } else if (Cc == '\n') {
X localecho('\n');
X localecho('\r');
X DWrite(chan, inputbuf, bp);
X bp = 0;
X } else {
X localecho(Cc);
X }
X
X iocr->io_Data = (APTR)&Cc;
X iocr->io_Length = 1;
X SendIO((RIO *)iocr);
X/*
X if (Cc == '\r') {
X Cc = '\n';
X DWrite(chan, &Cc, 1);
X iocr->io_Data = (APTR)&Cc;
X iocr->io_Length = 1;
X SendIO(iocr);
X }
X*/
X }
X }
X }
X AbortIO((RIO *)iocr);
X WaitIO((RIO *)iocr);
X SetWindowTitles(Win, "Closing...", (char *)-1);
X DClose(chan);
Xe3: CloseConsole(iocr,iocw);
X CloseWindow(Win);
Xe1: CloseLibrary((LIB *)IntuitionBase);
X CloseLibrary((LIB *)GfxBase);
X}
X
Xvoid
Xlocalecho(c)
Xint c;
X{
X char cc;
X
X cc = c;
X iocw->io_Data = (APTR)&cc;
X iocw->io_Length = 1;
X DoIO((RIO *)iocw);
X}
X
Xvoid
XOpenConsole(win, piocr, piocw)
XIOCON **piocr, **piocw;
XWIN *win;
X{
X PORT *port;
X static IOCON iocr, iocw;
X int error;
X
X port = CreatePort(NULL, 0);
X iocr.io_Command = CMD_READ;
X iocr.io_Data = (APTR)win;
X iocr.io_Message.mn_Node.ln_Type = NT_MESSAGE;
X iocr.io_Message.mn_ReplyPort = port;
X error = OpenDevice("console.device", 0, (RIO *)&iocr, 0);
X if (!error) {
X iocw = iocr;
X iocw.io_Command = CMD_WRITE;
X *piocr = &iocr;
X *piocw = &iocw;
X } else {
X *piocr = *piocw = NULL;
X }
X}
X
Xvoid
XCloseConsole(iocr, iocw)
XIOCON *iocr;
XIOCON *iocw;
X{
X IOCON *tmp = (iocr) ? iocr : iocw;
X if (tmp) {
X CloseDevice((RIO *)tmp);
X DeletePort(tmp->io_Message.mn_ReplyPort);
X }
X}
X
Xvoid
Xsetsize(iocw, chan, win)
XIOCON *iocw;
Xvoid *chan;
XWIN *win;
X{
X struct ConUnit *cu = (struct ConUnit *)iocw->io_Unit;
X static char IStr[] = { "\033c\23320l\233t\233u" };
X
X /*
X if (Cooked & 4)
X IStr[5] = 'h';
X else
X IStr[5] = 'l';
X */
X iocw->io_Data = (APTR)IStr;
X iocw->io_Length = sizeof(IStr) - 1;
X DoIO((RIO *)iocw);
X if (chan) {
X DIoctl(chan, CIO_SETROWS, (uword)(cu->cu_YMax+1), 0);
X DIoctl(chan, CIO_SETCOLS, (uword)(cu->cu_XMax+1), 0);
X }
X sprintf(Term, "FTERM %ld x %ld", cu->cu_YMax+1, cu->cu_XMax+1);
X SetWindowTitles(win, Term, (char *)-1);
X}
X
Xvoid
XHandleIoctl(cmd, val, aux, win, iocw)
Xshort cmd, val;
Xchar aux;
XWIN *win;
XIOCON *iocw;
X{
X static short saverows;
X short height, width;
X short dx, dy;
X
X switch(cmd) {
X case CIO_MODE:
X /*
X Cooked = val;
X */
X break;
X case CIO_SETROWS:
X saverows = val;
X break;
X case CIO_SETCOLS:
X width = val * win->RPort->TxWidth + win->BorderLeft + win->BorderRight;
X height= saverows * win->RPort->TxHeight + win->BorderTop + win->BorderBottom;
X
X dx = win->WScreen->Width - (win->LeftEdge + width);
X if (dx > 0)
X dx = 0;
X if (-dx > win->LeftEdge) {
X dx = -win->LeftEdge;
X width = win->WScreen->Width;
X }
X
X dy = win->WScreen->Height - (win->TopEdge + height);
X if (dy > 0)
X dy = 0;
X if (-dy > win->TopEdge) {
X dy = -win->TopEdge;
X height = win->WScreen->Height;
X }
X
X if (dx || dy) {
X MoveWindow(win, dx, dy);
X }
X if (win->Width != width || win->Height != height) {
X SizeWindow(win, width - win->Width, height - win->Height);
X ++IgnoreNS;
X }
X break;
X }
X}
X
END_OF_FILE
if test 7824 -ne `wc -c <'amiga/client/cliterm.c'`; then
echo shar: \"'amiga/client/cliterm.c'\" unpacked with wrong size!
fi
# end of 'amiga/client/cliterm.c'
fi
if test -f 'amiga/client/fterm.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/client/fterm.c'\"
else
echo shar: Extracting \"'amiga/client/fterm.c'\" \(9688 characters\)
sed "s/^X//" >'amiga/client/fterm.c' <<'END_OF_FILE'
X
X/*
X * FTERM.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * FTERM [-Nnet] [port] [-wcapturefile] [-c#]
X *
X * -c# = cooked mode. i.e. -c7 bit 0 convert CR's to LF's keyboard->remote
X * bit 1 echo chars locally (half duplex)
X * bit 2 received LF->CRLF
X */
X
X#include "defs.h"
X#include <local/deemu.h>
X
Xshort Deemu[] = {
X DMSTRT, 0, 0,
X DMNW , 0,10, 11, 11, -37, -28, 0xFFFF,
X DMTEXT, 0,30, 'FO','NT','\0t','op','az','.f','on','t.','8\0',0,0,0,0,0,0,
X DMEND , 0, 0
X};
X
X#define DMNWOFF 4
X#define DMFONTSTR 17
X
XTA Ta = { (ubyte *)"topaz.font", 8 };
X
XITEXT IText[] = {
X { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"Flush" },
X { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"AppendCap" },
X { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"NewCap" },
X { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"CloseCap" },
X { 0, 1, JAM2, 0, 0, &Ta, (ubyte *)"Paste" }
X};
X
XITEM Item[] = {
X { &Item[1], 0, 0, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[0], NULL, 'o' },
X { &Item[2], 0,10, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[1], NULL, 'a' },
X { &Item[3], 0,20, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[2], NULL, 'n' },
X { &Item[4], 0,30, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[3], NULL, 'c' },
X { NULL , 0,40, 100, 10, ITEMTEXT|COMMSEQ|ITEMENABLED|HIGHCOMP, 0, (APTR)&IText[4], NULL, 'p' }
X};
X
XMENU Menu[] = {
X { NULL , 0, 0, 100, 10+40, MENUENABLED, "Control", &Item[0] }
X};
X
Xubyte Title[80];
X
XNW Nw = {
X 0, 0, 640, 200, -1, -1,
X NEWSIZE|CLOSEWINDOW|MENUPICK,
X WINDOWSIZING|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|NOCAREREFRESH|ACTIVATE,
X NULL, NULL, Title, NULL, NULL,
X 32, 32, -1, -1, WBENCHSCREEN
X};
X
XWIN *Win;
X
Xextern int Enable_Abort;
Xchar Buf[512];
Xchar Term[64];
Xchar Cc;
Xchar Cooked; /* bit 0 = cooked, bit 1 = local echo */
Xchar IgnoreNS;
X
X
X
Xstruct IntuitionBase *IntuitionBase;
Xstruct GfxBase *GfxBase;
X
Xvoid OpenConsole ARGS((WIN *, IOCON **, IOCON **));
Xvoid HandleIoctl ARGS((short, short, char, WIN *, IOCON *));
Xvoid CloseConsole ARGS((IOCON *, IOCON *));
Xvoid setsize ARGS((IOCON *, void *, WIN *));
X
Xvoid main ARGS((int, char **));
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
Xmain(ac, av)
Xchar *av[];
X{
X void *chan;
X long imask, conmask, dmask, mask;
X IOCON *iocr, *iocw;
X char notdone = 1;
X char portspec = 0;
X char *host = NULL;
X char *capfile = NULL;
X FILE *capfi = NULL;
X uword port = PORT_IALPHATERM;
X FONT *font = NULL;
X
X onbreak(brk);
X sprintf(Title, "FTerm V%s%s", VERSION, FTERM_VERSION);
X strcpy(Term, Title);
X strcat(Title, " opening, wait ...");
X
X {
X char *str = av[0];
X for (str = str + strlen(str); str >= av[0]; --str) {
X if (*str == '/' || *str == ':')
X break;
X }
X ++str;
X if ((*str | 0x20) == 'b') /* bbsterm instead of fterm */
X port = PORT_BBS;
X }
X
X {
X short i;
X for (i = 1; i < ac; ++i) {
X char *ptr = av[i];
X if (*ptr == '-') {
X while (*++ptr) {
X switch(*ptr) {
X case 'N':
X host = ptr + 1;
X ptr = "\0";
X break;
X case 'w':
X capfile = ptr + 1;
X ptr = "\0";
X break;
X case 'c':
X Cooked = atoi(ptr + 1);
X ptr = "\0";
X break;
X default:
X printf("Unknown option: '%c'\n", *ptr);
X break;
X }
X }
X } else {
X portspec = 1;
X port = atoi(ptr);
X }
X }
X }
X if (capfile)
X capfi = fopen(capfile, "a");
X if (portspec)
X printf("Using port %ld\n", port);
X#ifndef LATTICE
X Enable_Abort = 0;
X#endif
X IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
X GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);
X
X InitDeemuNW(Deemu+DMNWOFF, &Nw);
X {
X char *p1, *p2;
X p1 = (char *)(Deemu+DMFONTSTR) + strlen((char *)(Deemu+DMFONTSTR)) + 1;
X for (p2 = p1 + strlen(p1); p2 != p1 && *p2 != '.'; --p2);
X if (*p2 == '.') {
X *p2 = 0;
X font = (FONT *)GetFont(p1, (short)atoi(p2+1));
X }
X }
X
X Win = OpenWindow(&Nw);
X if (Win == NULL)
X goto e1;
X if (font) {
X SetFont(Win->RPort, font);
X SetRast(Win->RPort, 0);
X RefreshWindowFrame(Win);
X }
X OpenConsole(Win, &iocr, &iocw);
X if (iocr == NULL || iocw == NULL)
X goto e3;
X
X /*
X * We delay here to allow DNET to go through its RESTART sequence
X * (when DNET automatically runs FTERM, it does so to quickly).
X * Such a hack!
X */
X
X Delay(50 * 4);
X chan = DOpen(host, port, 20, 15);
X
X if (!chan) {
X puts("Unable to connect");
X goto e3;
X }
X DQueue(chan, 32);
X SetMenuStrip(Win, Menu);
X SetWindowTitles(Win, Term, (char *)-1);
X imask = 1 << Win->UserPort->mp_SigBit;
X dmask = 1 << ((PORT *)chan)->mp_SigBit;
X conmask = 1 << iocr->io_Message.mn_ReplyPort->mp_SigBit;
X
X iocr->io_Data = (APTR)&Cc;
X iocr->io_Length = 1;
X SendIO(iocr);
X
X setsize(iocw, chan, Win);
X while (notdone) {
X mask = Wait(imask|dmask|conmask);
X if (mask & imask) {
X IMESS *im;
X while (im = (IMESS *)GetMsg(Win->UserPort)) {
X switch(im->Class) {
X case NEWSIZE:
X if (IgnoreNS) {
X --IgnoreNS;
X setsize(iocw, NULL, Win);
X } else {
X setsize(iocw, chan, Win);
X }
X break;
X case CLOSEWINDOW:
X notdone = 0;
X break;
X case MENUPICK:
X switch((uword)((MENUNUM(im->Code)<<8)|ITEMNUM(im->Code))) {
X case 0x0000: /* menu 0 item 0 */
X DIoctl(chan, CIO_FLUSH, 0, 0);
X break;
X case 0x0001: /* menu 0 item 1 */
X if (capfi)
X fclose(capfi);
X capfi = fopen("ram:capture", "a");
X break;
X case 0x0002:
X if (capfi)
X fclose(capfi);
X capfi = fopen("ram:capture", "w");
X break;
X case 0x0003: /* menu 0 item 2 */
X if (capfi)
X fclose(capfi);
X capfi = NULL;
X break;
X case 0x0004: /* menu 0 item 3 */
X {
X FILE *fi;
X long n;
X if (fi = fopen("ram:paste", "r")) {
X while ((n = fread(Buf, 1, sizeof(Buf), fi)) > 0) {
X DWrite(chan, Buf, n);
X }
X fclose(fi);
X }
X }
X break;
X case 0x0100: /* menu 1 item 0 */
X break;
X }
X }
X ReplyMsg((MSG *)im);
X }
X }
X if (mask & dmask) {
X int n;
X if ((n = DNRead(chan, Buf, sizeof(Buf))) > 0) {
X iocw->io_Data = (APTR)Buf;
X iocw->io_Length = n;
X DoIO(iocw);
X if (capfi)
X fwrite(Buf, n, 1, capfi);
X } else if (n == -2) {
X short val;
X short cmd;
X char aux;
X cmd = DGetIoctl(chan, &val, &aux);
X HandleIoctl(cmd, val, aux, Win, iocw);
X if (cmd == CIO_MODE) {
X if (val)
X SetWindowTitles(Win, "(Cooked)", (char *)-1);
X else
X SetWindowTitles(Win, "(Raw)", (char *)-1);
X }
X } else if (n < 0) {
X notdone = 0;
X }
X }
X if (mask & conmask) {
X if (CheckIO(iocr)) {
X WaitIO(iocr);
X if (Cooked & 2) { /* Local Echo */
X iocw->io_Data = (APTR)&Cc;
X iocw->io_Length = 1;
X DoIO(iocw);
X }
X if ((Cooked & 1) && Cc == 13) {
X Cc = 10;
X iocw->io_Data = (APTR)&Cc;
X iocw->io_Length = 1;
X DoIO(iocw);
X }
X DWrite(chan, &Cc, 1);
X iocr->io_Data = (APTR)&Cc;
X iocr->io_Length = 1;
X SendIO(iocr);
X }
X }
X }
X AbortIO(iocr);
X WaitIO(iocr);
X SetWindowTitles(Win, "Closing...", (char *)-1);
X DClose(chan);
Xe3: CloseConsole(iocr,iocw);
X if (font) {
X SetFont(Win->RPort, Win->WScreen->RastPort.Font);
X CloseFont(font);
X }
X CloseWindow(Win);
Xe1: CloseLibrary((LIB *)IntuitionBase);
X CloseLibrary((LIB *)GfxBase);
X if (capfi)
X fclose(capfi);
X}
X
Xvoid
XOpenConsole(win, piocr, piocw)
XIOCON **piocr, **piocw;
XWIN *win;
X{
X PORT *port;
X static IOCON iocr, iocw;
X int error;
X
X port = CreatePort(NULL, 0);
X iocr.io_Command = CMD_READ;
X iocr.io_Data = (APTR)win;
X iocr.io_Message.mn_Node.ln_Type = NT_MESSAGE;
X iocr.io_Message.mn_ReplyPort = port;
X error = OpenDevice("console.device", 0, &iocr, 0);
X if (!error) {
X iocw = iocr;
X iocw.io_Command = CMD_WRITE;
X *piocr = &iocr;
X *piocw = &iocw;
X } else {
X *piocr = *piocw = NULL;
X }
X}
X
Xvoid
XCloseConsole(iocr, iocw)
XIOCON *iocr;
XIOCON *iocw;
X{
X IOCON *tmp = (iocr) ? iocr : iocw;
X if (tmp) {
X CloseDevice(tmp);
X DeletePort(tmp->io_Message.mn_ReplyPort);
X }
X}
X
Xvoid
Xsetsize(iocw, chan, win)
XIOCON *iocw;
Xvoid *chan;
XWIN *win;
X{
X struct ConUnit *cu = (struct ConUnit *)iocw->io_Unit;
X static char IStr[] = { "\033c\23320l\233t\233u" };
X
X if (Cooked & 4)
X IStr[5] = 'h';
X else
X IStr[5] = 'l';
X iocw->io_Data = (APTR)IStr;
X iocw->io_Length = sizeof(IStr) - 1;
X DoIO(iocw);
X if (chan) {
X DIoctl(chan, CIO_SETROWS, (uword)(cu->cu_YMax+1), 0);
X DIoctl(chan, CIO_SETCOLS, (uword)(cu->cu_XMax+1), 0);
X }
X sprintf(Term, "FTERM %ld x %ld", cu->cu_YMax+1, cu->cu_XMax+1);
X SetWindowTitles(win, Term, (char *)-1);
X}
X
Xvoid
XHandleIoctl(cmd, val, aux, win, iocw)
Xshort cmd, val;
Xchar aux;
XWIN *win;
XIOCON *iocw;
X{
X static short saverows;
X short height, width;
X short dx, dy;
X
X switch(cmd) {
X case CIO_MODE:
X Cooked = val;
X break;
X case CIO_SETROWS:
X saverows = val;
X break;
X case CIO_SETCOLS:
X width = val * win->RPort->TxWidth + win->BorderLeft + win->BorderRight;
X height= saverows * win->RPort->TxHeight + win->BorderTop + win->BorderBottom;
X
X dx = win->WScreen->Width - (win->LeftEdge + width);
X if (dx > 0)
X dx = 0;
X if (-dx > win->LeftEdge) {
X dx = -win->LeftEdge;
X width = win->WScreen->Width;
X }
X
X dy = win->WScreen->Height - (win->TopEdge + height);
X if (dy > 0)
X dy = 0;
X if (-dy > win->TopEdge) {
X dy = -win->TopEdge;
X height = win->WScreen->Height;
X }
X
X if (dx || dy) {
X MoveWindow(win, dx, dy);
X }
X if (win->Width != width || win->Height != height) {
X SizeWindow(win, width - win->Width, height - win->Height);
X ++IgnoreNS;
X }
X break;
X }
X}
X
X
END_OF_FILE
if test 9688 -ne `wc -c <'amiga/client/fterm.c'`; then
echo shar: \"'amiga/client/fterm.c'\" unpacked with wrong size!
fi
# end of 'amiga/client/fterm.c'
fi
if test -f 'amiga/client/getfiles.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/client/getfiles.c'\"
else
echo shar: Extracting \"'amiga/client/getfiles.c'\" \(8775 characters\)
sed "s/^X//" >'amiga/client/getfiles.c' <<'END_OF_FILE'
X
X/*
X * GETFILES.C V1.30
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X *
X * GETFILES [-Nnetid] [-dlocaldir] [-c] file/dir file/dir file/dir
X *
X * -Nnetid network identifier
X *
X * -dlocaldir local directory to place files
X *
X * -c Continue from where you left off before. Files that already
X * exist on the local machine will not be re-transfered. This
X * will also re-start in the middle of a file that was
X * partially transfered previously.
X *
X * This command assumes the file(s) on both machines have not
X * been modified since the first attempt. No other checking
X * is done at the moment.
X */
X
X#include "defs.h"
X
Xvoid main ARGS((int, char **));
X
Xtypedef struct {
X char Cmd;
X char Str[128];
X long Val;
X} HDR;
X
X
Xextern int Enable_Abort;
X
Xchar Buf[4096];
X
Xshort ContMode;
Xchar *NetId;
Xlong LocalDirLock;
Xvoid *Chan;
X
Xvoid fail ARGS((int));
Xint CheckNoPath ARGS((char *));
Xint LostChannel ARGS((void));
Xvoid UnknownCmd ARGS((HDR *));
Xint GetFile ARGS((HDR *, int));
Xint GetDir ARGS((HDR *, int));
Xint WriteHeader ARGS((char, char *, long));
Xint ReadHeader ARGS((HDR *));
Xchar *NSpaces ARGS((int));
Xint CheckBreak ARGS((void));
Xvoid ResetBreak ARGS((void));
X
Xint brk()
X{
X return(0);
X}
X
X
Xvoid
Xmain(ac,av)
Xint ac;
Xchar *av[];
X{
X HDR Hdr;
X short error;
X
X onbreak(brk);
X#ifndef LATTICE
X Enable_Abort = 0;
X#endif
X printf("GetFiles V%s%s\n", VERSION, GETFILES_VERSION);
X ResetBreak();
X {
X char *ldir = "";
X FIB *fib = malloc(sizeof(FIB));
X ac = DoOption(ac, av, "N%sd%sc", &NetId, &ldir, &ContMode);
X if (ac <= 1) {
X puts("GETFILES [-Nnetid -dlocaldir -c] remotefile/dir ...");
X fail(22);
X }
X LocalDirLock = Lock(ldir, SHARED_LOCK);
X if (!LocalDirLock && ldir[0]) { /* couldn't find it, try to make it */
X if (LocalDirLock = (long)CreateDir(ldir)) {
X UnLock(LocalDirLock);
X LocalDirLock = Lock(ldir, SHARED_LOCK);
X }
X }
X if (!LocalDirLock || !Examine(LocalDirLock, fib) || fib->fib_DirEntryType < 0) {
X printf("Unable to CD or create local directory: \"%s\"\n", ldir);
X fail(21);
X }
X }
X Chan = DOpen(NetId, PORT_GFILECOPY, 126, -80);
X if (!Chan) {
X puts("Unable to connect");
X fail(20);
X }
X error = WriteHeader('H', "Hello, getfiles client V1.30", 0);
X if (error)
X fail(LostChannel());
X switch(ReadHeader(&Hdr)) {
X case -1:
X fail(LostChannel());
X case 'H':
X printf("%s\n", Hdr.Str);
X break;
X }
X {
X short i;
X
X for (i = 1; i < ac; ++i) {
X short error;
X
X error = WriteHeader('G', av[i], 0);
X if (error)
X fail(LostChannel());
X switch(ReadHeader(&Hdr)) {
X case -1:
X fail(LostChannel());
X case 'N':
X printf("Remote error on %s: %s\n", av[i], Hdr.Str);
X break;
X case 'F':
X error = CheckNoPath(Hdr.Str);
X if (!error) {
X long olddir = (long)CurrentDir(LocalDirLock);
X error = GetFile(&Hdr, 0);
X CurrentDir(olddir);
X }
X break;
X case 'D':
X error = CheckNoPath(Hdr.Str);
X if (!error) {
X long olddir = (long)CurrentDir(LocalDirLock);
X error = GetDir(&Hdr, 0);
X CurrentDir(olddir);
X }
X break;
X case 'S':
X printf("Access Violation: %s\n", Hdr.Str);
X break;
X default:
X UnknownCmd(&Hdr);
X error = 1;
X break;
X }
X if (error)
X fail(error);
X }
X if (!error) {
X error = WriteHeader('E', "bye", 0);
X if (error)
X fail(LostChannel());
X }
X }
X fail(0);
X}
X
Xvoid
Xfail(code)
X{
X if (Chan)
X DClose(Chan);
X if (LocalDirLock)
X UnLock(LocalDirLock);
X exit(code);
X}
X
Xint
XCheckNoPath(str)
Xchar *str;
X{
X while (*str) {
X if (*str == '/' || *str == ':') {
X puts("SECURITY ALERT: Illegal path spec received");
X return(40);
X }
X ++str;
X }
X return(0);
X}
X
Xint
XLostChannel()
X{
X puts("DATA CHANNEL LOST");
X return(10);
X}
X
Xvoid
XUnknownCmd(hdr)
XHDR *hdr;
X{
X printf("UnRecognized command code: %02x\n", hdr->Cmd);
X}
X
X/*
X * retrieve a file. If ContMode set and file exists, try to append to
X * it.
X */
X
Xint
XGetFile(hdr, stab)
XHDR *hdr;
Xint stab;
X{
X long Fh = NULL;
X long pos = 0;
X short error = 0;
X
X printf("%s%-20s ", NSpaces(stab), hdr->Str);
X fflush(stdout);
X if (ContMode) {
X SetProtection(hdr->Str, 0); /* make sure it's r/w */
X if (Fh = Open(hdr->Str, 1005)) { /* already exists */
X long len;
X
X Seek(Fh, 0L, 1);
X len = Seek(Fh, 0L, 0); /* get length */
X if (len > hdr->Val) {
X Close(Fh);
X printf("Cont Error, local file is larger than remote!: %s\n", hdr->Str);
X puts("(not downloaded)");
X return(0);
X }
X if (len == hdr->Val) {
X Close(Fh);
X if (error = WriteHeader('S', NULL, 0))
X return(LostChannel());
X puts("HAVE IT, SKIP");
X return(0);
X }
X printf("(HAVE %ld/%ld) ", len, hdr->Val);
X hdr->Val -= len; /* that much less */
X pos = len; /* start at offset */
X }
X }
X if (!Fh) {
X Fh = Open(hdr->Str, 1006);
X if (!Fh) {
X error = WriteHeader('N', "open error", 0);
X printf("Unable to open %s for output\n", hdr->Str);
X if (error)
X return(LostChannel());
X return(1);
X }
X }
X error = WriteHeader('Y', NULL, pos); /* yes, gimme gimme */
X
X /*
X * Retrieve the data
X */
X
X if (!error) {
X long left = hdr->Val;
X long cnt = pos;
X long total = pos + left;
X
X while (left) {
X long n = (left > sizeof(Buf)) ? sizeof(Buf) : left;
X printf("%6ld/%6ld\23313D", cnt, total);
X fflush(stdout);
X if (DRead(Chan, Buf, n) != n) {
X error = 5;
X break;
X }
X if (CheckBreak()) {
X error = 1;
X break;
X }
X if (Write(Fh, Buf, n) != n) {
X puts("Local Write failed!");
X error = 6;
X break;
X }
X left -= n;
X cnt += n;
X if (CheckBreak()) {
X error = 1;
X break;
X }
X }
X printf("%6ld/%6ld %s", cnt, total, ((cnt == total) ? "OK" : "INCOMPLETE"));
X }
X Close(Fh);
X puts("");
X if (error) {
X SetProtection(hdr->Str, 10); /* disallow reads! */
X return(LostChannel());
X }
X return((int)error);
X}
X
X/*
X * Retrieve a directory. Create it if necessary.
X */
X
Xint
XGetDir(hdr, stab)
XHDR *hdr;
Xint stab;
X{
X short error = 0;
X long dirlock;
X static HDR Hdr; /* note: static */
X
X if (CheckBreak())
X return(1);
X printf("%s%-20s(DIR)\n", NSpaces(stab), hdr->Str);
X dirlock = Lock(hdr->Str, SHARED_LOCK); /* try to lock directory */
X if (!dirlock) {
X if (dirlock = (long)CreateDir(hdr->Str)) {
X UnLock(dirlock);
X dirlock = Lock(hdr->Str, SHARED_LOCK);
X }
X }
X if (!dirlock) {
X error = WriteHeader('N', "couldn't create", 0);
X printf("Unable to create local directory: %s\n", hdr->Str);
X if (error)
X return(LostChannel());
X return(1);
X }
X error = WriteHeader('Y', NULL, 0); /* yes, gimme gimme */
X while (!error) {
X switch(ReadHeader(&Hdr)) {
X case -1:
X error = 1;
X break;
X case 'E': /* end of directory */
X UnLock(dirlock);
X return(0);
X break;
X case 'F':
X error = CheckNoPath(Hdr.Str);
X if (!error) {
X long olddir = (long)CurrentDir(dirlock);
X error = GetFile(&Hdr, stab + 4);
X CurrentDir(olddir);
X }
X break;
X case 'D':
X error = CheckNoPath(Hdr.Str);
X if (!error) {
X long olddir = (long)CurrentDir(dirlock);
X error = GetDir(&Hdr, stab + 4);
X CurrentDir(olddir);
X }
X break;
X case 'S':
X printf("Access Violation: %s\n", Hdr.Str);
X break;
X case 'N':
X printf("REMOTE ERROR: %s\n", Hdr.Str);
X error = 10;
X break;
X default:
X UnknownCmd(&Hdr);
X error = 1;
X break;
X }
X }
X UnLock(dirlock);
X return(LostChannel());
X}
X
Xint
XWriteHeader(c, str, len)
Xchar c;
Xchar *str;
Xlong len;
X{
X ubyte sl;
X
X if (str == NULL)
X str = "";
X sl = strlen(str);
X
X if (DWrite(Chan, &c, 1) < 0)
X return(1);
X if (DWrite(Chan, &sl,1) < 0)
X return(1);
X if (DWrite(Chan, str, sl) != sl)
X return(1);
X if (DWrite(Chan, &len, 4) != 4)
X return(1);
X return(0);
X}
X
Xint
XReadHeader(hdr)
XHDR *hdr;
X{
X ubyte sl;
X ubyte cmd;
X
X hdr->Cmd = -1;
X if (DRead(Chan, &cmd, 1) != 1)
X return(-1);
X if (DRead(Chan, &sl, 1) != 1)
X return(-1);
X if (sl >= sizeof(hdr->Str)) {
X puts("Software error: received file name length too long");
X return(-1);
X }
X if (DRead(Chan, hdr->Str, sl) != sl)
X return(-1);
X hdr->Str[sl] = 0;
X if (DRead(Chan, &hdr->Val, 4) != 4)
X return(-1);
X hdr->Cmd = cmd;
X return((int)hdr->Cmd);
X}
X
Xchar *
XNSpaces(n)
Xint n;
X{
X static char Buf[128];
X static short in = 0;
X static short last;
X
X if (in == 0) {
X in = 1;
X BSet(Buf, sizeof(Buf)-1, ' ');
X }
X Buf[last] = ' ';
X if (n < 127)
X Buf[n] = 0;
X last = n;
X return(Buf);
X}
X
Xint
XCheckBreak()
X{
X if (SetSignal(0,0) & (SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D)) {
X puts("^C");
X return(1);
X }
X return(0);
X}
X
Xvoid
XResetBreak()
X{
X SetSignal(0, SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D);
X}
X
END_OF_FILE
if test 8775 -ne `wc -c <'amiga/client/getfiles.c'`; then
echo shar: \"'amiga/client/getfiles.c'\" unpacked with wrong size!
fi
# end of 'amiga/client/getfiles.c'
fi
if test -f 'amiga/dnet/sernet.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/dnet/sernet.c'\"
else
echo shar: Extracting \"'amiga/dnet/sernet.c'\" \(8314 characters\)
sed "s/^X//" >'amiga/dnet/sernet.c' <<'END_OF_FILE'
X
X/*
X * SERNET.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * NetWork device interface.
X */
X
X#include "dnet.h"
X
XIOSER *NetAbortRead();
Xvoid NetWaitWrite();
Xvoid SaveState();
Xvoid RestoreState();
Xvoid NetSerialOff();
Xvoid NetSerialOn();
X
Xstatic IOSER Iosw;
Xstatic ubyte IoswIP;
Xstatic ubyte LastWasWrite;
X
Xstatic ubyte IosrIP;
Xstatic ubyte RBuf[MAXPACKET*2]; /* Recv Buf. */
X
Xstatic IOSER *CNet; /* control-req (synchro) */
Xstatic IOSER *RNet; /* read-request */
Xstatic ubyte SerialIsOpen; /* serial device is open */
Xstatic ubyte RecvEnabled = 1;
Xstatic char *DevName;
Xstatic long UnitNum;
X
Xvoid
XNetOpen(iosink, devname, unitnum, pbaud)
XPORT *iosink;
Xchar *devname;
Xlong *pbaud;
X{
X IOSER ios;
X long baud = *pbaud;
X
X DevName = devname;
X UnitNum = unitnum;
X
X printf("netopen %s %d\n", devname, unitnum);
X
X BZero(&ios, sizeof(ios));
X ios.io_CtlChar = 0x11130102;
X ios.io_SerFlags = SERF_SHARED;
X if (OpenDevice(devname, unitnum, (IOR *)&ios, 0))
X dneterror(devname);
X ios.IOSer.io_Message.mn_ReplyPort = iosink;
X SerialIsOpen = 1;
X
X RNet = (IOSER *)AllocMem(sizeof(IOSER), MEMF_PUBLIC);
X CNet = (IOSER *)AllocMem(sizeof(IOSER), MEMF_PUBLIC);
X *RNet = ios;
X *CNet = ios;
X
X {
X IOSER *ioc = CNet;
X
X ioc->IOSer.io_Command = SDCMD_QUERY;
X DoIO((IOR *)ioc);
X
X if (Getty == 0) {
X ioc->IOSer.io_Command = SDCMD_SETPARAMS;
X
X if (baud)
X ioc->io_Baud = baud;
X
X ioc->io_SerFlags |= SERF_SHARED;
X ioc->io_CtlChar = 0x01020304;
X
X if (Protocol >= 0) {
X ioc->io_SerFlags |= SERF_XDISABLED|SERF_RAD_BOOGIE;
X
X switch(Protocol) {
X case 0:
X break;
X case 1: /* xon-xoff */
X Mode7 = 1;
X ioc->io_SerFlags &= ~(SERF_XDISABLED | SERF_RAD_BOOGIE);
X break;
X case 2:
X case 7:
X ioc->io_SerFlags |= SERF_7WIRE;
X break;
X }
X }
X
X if (Parity >= 0) {
X ioc->io_ReadLen = ioc->io_WriteLen = 7;
X ioc->io_SerFlags &= ~(SERF_PARTY_ON|SERF_PARTY_ODD);
X ioc->io_ExtFlags &= ~(SEXTF_MSPON|SEXTF_MARK);
X ioc->io_SerFlags &= ~SERF_RAD_BOOGIE;
X switch(Parity) {
X case 0:
X ioc->io_ReadLen = ioc->io_WriteLen = 8;
X if (Protocol != 1)
X ioc->io_SerFlags |= SERF_RAD_BOOGIE;
X break;
X case 1:
X ioc->io_SerFlags |= SERF_PARTY_ON | SERF_PARTY_ODD;
X break;
X case 2:
X ioc->io_SerFlags |= SERF_PARTY_ON;
X break;
X case 3:
X ioc->io_SerFlags |= SERF_PARTY_ON;
X ioc->io_ExtFlags |= SEXTF_MSPON | SEXTF_MARK;
X break;
X case 4:
X ioc->io_SerFlags |= SERF_PARTY_ON;
X ioc->io_ExtFlags |= SEXTF_MSPON;
X break;
X }
X }
X printf("parity is ");
X if (ioc->io_SerFlags & SERF_PARTY_ON) {
X if (ioc->io_ExtFlags & SEXTF_MSPON) {
X if (ioc->io_ExtFlags & SEXTF_MARK)
X puts("mark");
X else
X puts("space");
X } else {
X if (ioc->io_SerFlags & SERF_PARTY_ODD)
X puts("odd");
X else
X puts("even");
X }
X } else {
X puts("off");
X }
X printf("protocol is ");
X if (ioc->io_SerFlags & SERF_7WIRE)
X printf("7wire ");
X if ((ioc->io_SerFlags & SERF_XDISABLED) == 0)
X printf("xon-xoff");
X if ((ioc->io_SerFlags & SERF_7WIRE) == 0 && (ioc->io_SerFlags & SERF_XDISABLED))
X printf("none");
X puts("");
X fflush(stdout);
X
X *pbaud = Baud = ioc->io_Baud;
X if (DoIO((IOR *)ioc) != 0)
X dneterror("Unable to set serial parameters");
X }
X }
X
X RNet->IOSer.io_Command = CMD_READ;
X RNet->IOSer.io_Message.mn_Node.ln_Name = (char *)RNET_REQ;
X
X CNet->IOSer.io_Command = CMD_WRITE;
X CNet->IOSer.io_Message.mn_Node.ln_Name = (char *)WNET_REQ;
X
X Iosw = *CNet;
X
X CNet->IOSer.io_Message.mn_Node.ln_Name = (char *)CNET_REQ;
X
X puts("net open");
X}
X
X/*
X * Closedown the network.
X */
X
Xvoid
XNetClose()
X{
X NetAbortRead();
X NetWaitWrite();
X if (SerialIsOpen)
X CloseDevice((IOR *)RNet);
X if (RNet)
X FreeMem(RNet, sizeof(IOSER));
X if (CNet)
X FreeMem(CNet, sizeof(IOSER));
X SerialIsOpen = 0;
X RNet = CNet = NULL;
X}
X
X/*
X * NETCLWRITE()
X *
X * Clear write request which was GetMsg()'d in DNET.C instead of
X * WaitIO()'d here.
X */
X
Xvoid
XNetClWrite(ior)
XIOSER *ior;
X{
X if (ior == &Iosw)
X IoswIP = 0;
X}
X
Xvoid
XNetWrite(buf, bytes)
Xubyte *buf;
Xint bytes;
X{
X if (PDebug) {
X short i;
X
X LastWasWrite = 1;
X printf("WRITE %03x Bytes:", bytes);
X for (i = 0; i < bytes; ++i)
X printf(" %02x", buf[i]);
X printf("\n");
X }
X
X if (!SerialIsOpen)
X return;
X
X if (IoswIP) {
X WaitIO((IOR *)&Iosw);
X IoswIP = 0;
X }
X
X if (bytes) {
X Iosw.IOSer.io_Message.mn_Node.ln_Name = (char *)WNET_REQ;
X Iosw.IOSer.io_Data = (APTR)buf;
X Iosw.IOSer.io_Length = bytes;
X SendIO((IOR *)&Iosw);
X IoswIP = 1;
X }
X fixsignal(Iosw.IOSer.io_Message.mn_ReplyPort);
X}
X
Xvoid
XNetBreak()
X{
X if (SerialIsOpen) {
X CNet->IOSer.io_Command = SDCMD_BREAK;
X DoIO((IOR *)CNet);
X fixsignal(Iosw.IOSer.io_Message.mn_ReplyPort);
X }
X}
X
X/*
X * NETREADY()
X *
X * Using the specified inactive request, return the # bytes ready and
X * the carrier status.
X */
X
XNetReady()
X{
X long n = 0;
X
X if (SerialIsOpen && RecvEnabled) {
X CNet->IOSer.io_Command = SDCMD_QUERY;
X if (DoIO((IOR *)CNet) == 0)
X n = CNet->IOSer.io_Actual;
X Cd = !(CNet->io_Status & (1 << 5));
X }
X return(n);
X}
X
X/*
X * SetBaudRate()
X */
X
XSetBaudRate(baud)
Xlong baud;
X{
X long result;
X
X if (Getty)
X return(0);
X if (TOBaud == 0)
X SetTimeouts(baud);
X if (CNet)
X CNet->io_Baud = baud;
X if (!SerialIsOpen)
X return(1);
X SaveState();
X CNet->IOSer.io_Command = SDCMD_SETPARAMS;
X result = DoIO((IOR *)CNet);
X RestoreState();
X
X if (result)
X printf("Unable to set baud rate to %d\n", baud);
X
X if (!result && PDebug)
X printf("Baud rate set to %d\n", baud);
X
X return(0); /* don't abort whether we can or not */
X}
X
X/*
X * Assumes CNet holds current settings
X */
X
Xvoid
XDropDTR()
X{
X if (SerialIsOpen) { /* only if serial.device currently open */
X NetSerialOff();
X Delay(50*4);
X NetSerialOn();
X }
X}
X
XIOSER *
XNetAbortRead()
X{
X if (IosrIP) {
X if (SerialIsOpen && RecvEnabled) {
X AbortIO((IOR *)RNet);
X WaitIO((IOR *)RNet);
X }
X IosrIP = 0;
X }
X return(RNet);
X}
X
X/*
X * NetStartRead(bytes)
X */
X
Xstatic long SaveLen;
X
Xvoid
XNetStartRead(len)
Xlong len;
X{
X if (len > sizeof(RBuf))
X len = sizeof(RBuf);
X
X if (SerialIsOpen && RecvEnabled) {
X if (IosrIP)
X NetAbortRead();
X RNet->IOSer.io_Data = (APTR)RBuf;
X SaveLen = RNet->IOSer.io_Length = len;
X SendIO((IOR *)RNet);
X } else {
X SaveLen = len;
X RNet->IOSer.io_Actual = 0;
X }
X IosrIP = 1;
X}
X
XIOSER *
XNetReadReady()
X{
X return((IOSER *)CheckIO((IOR *)RNet));
X}
X
XNetReadReturned(pptr)
Xubyte **pptr;
X{
X long bytes = 0;
X
X IosrIP = 0;
X
X bytes = RNet->IOSer.io_Actual;
X *pptr = RBuf;
X
X if (PDebug) {
X short i = 0;
X if (LastWasWrite) {
X LastWasWrite = 0;
X printf("READ: ");
X }
X for (i = 0; i < bytes; ++i)
X printf("%02x ", RBuf[i]);
X fflush(stdout);
X }
X return(bytes);
X}
X
Xvoid
XNetWaitWrite()
X{
X if (IoswIP) {
X WaitIO((IOR *)&Iosw);
X IoswIP = 0;
X fixsignal(Iosw.IOSer.io_Message.mn_ReplyPort);
X }
X}
X
Xstatic char SaveIosrIP;
X
Xvoid
XSaveState()
X{
X if (SaveIosrIP = IosrIP)
X NetAbortRead();
X NetWaitWrite();
X}
X
Xvoid
XRestoreState()
X{
X if (SaveIosrIP)
X NetStartRead(SaveLen);
X}
X
Xvoid
XNetRecvOff()
X{
X if (RecvEnabled) {
X SaveState();
X RecvEnabled = 0;
X }
X}
X
Xvoid
XNetRecvOn()
X{
X if (!RecvEnabled) {
X RecvEnabled = 1;
X RestoreState();
X }
X}
X
Xvoid
XNetSerialOff()
X{
X if (SerialIsOpen) {
X SaveState(); /* make sure no requests pending */
X CloseDevice((IOR *)RNet); /* close the device */
X SerialIsOpen = 0;
X }
X}
X
Xvoid
XNetSerialOn()
X{
X if (!SerialIsOpen) {
X if (OpenDevice(DevName, UnitNum, (IOR *)RNet, 0)) /* OH HELL! */
X return;
X
X /*
X * Fix the Device / Unit fields and restore the previous
X * modes.
X */
X
X SerialIsOpen = 1;
X Iosw.IOSer.io_Device = RNet->IOSer.io_Device;
X Iosw.IOSer.io_Unit = RNet->IOSer.io_Unit;
X
X CNet->IOSer.io_Device = RNet->IOSer.io_Device;
X CNet->IOSer.io_Unit = RNet->IOSer.io_Unit;
X
X RNet->IOSer.io_Command = CMD_READ;
X /* restore params */
X CNet->IOSer.io_Command = SDCMD_SETPARAMS;
X CNet->io_SerFlags = SERF_SHARED|SERF_XDISABLED|SERF_RAD_BOOGIE;
X DoIO((IOR *)CNet);
X RestoreState(); /* restore pending read req. */
X }
X return;
X}
X
END_OF_FILE
if test 8314 -ne `wc -c <'amiga/dnet/sernet.c'`; then
echo shar: \"'amiga/dnet/sernet.c'\" unpacked with wrong size!
fi
# end of 'amiga/dnet/sernet.c'
fi
if test -f 'amiga/server/sgcopy.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/server/sgcopy.c'\"
else
echo shar: Extracting \"'amiga/server/sgcopy.c'\" \(8179 characters\)
sed "s/^X//" >'amiga/server/sgcopy.c' <<'END_OF_FILE'
X
X/*
X * SGCOPY.C V1.1
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * GET-COPY SERVER (NEW COPY SERVER)
X *
X * The current version only accepts one connection at a time. This server
X * will send requested files to the remote machine.
X *
X * length in 68000 longword format.
X *
X * ACCESS RESTRICTIONS:
X *
X * Remote access restrictions are according to DNET_GROUP or DNET_READ
X *
X * DNET_READ >= 9 Full Access
X * DNET_READ < 9 According to comment field (AC=n) or group acc.
X * (GR=n) matches DNET_GROUP)
X *
X * When searching for access rights, the comment field of the file/dir
X * requested is checked first. If empty, the parent dir is checked.
X * This continues (parent diring) until root is found or a comment
X * field with access info in it.
X */
X
X#include "defs.h"
X
Xtypedef struct {
X char Cmd;
X char Str[64];
X long Val;
X} HDR;
X
Xextern int Enable_Abort;
Xchar Buf[8192];
Xvoid *Chan;
X
Xvoid SGCopy ARGS((void));
Xint PutObject ARGS((char *));
Xint PutDir ARGS((char *, int));
Xint PutFile ARGS((char *, int));
Xint WriteHeader ARGS((char, char *, long));
Xint ReadHeader ARGS((HDR *));
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
X#ifdef LATTICE
X_main(str)
X#else
X_main(len,str)
X#endif
Xchar *str;
X{
X struct MsgPort *port;
X PROC *myproc = (PROC *)FindTask(NULL);
X long savedir;
X long mask, rmask;
X
X onbreak(brk);
X
X if (strncmp(str, "__dnet", 6) != 0) {
X Version("SGCopy", VERSION, SGCOPY_VERSION);
X _exit(0);
X }
X
X port = DListen(PORT_GFILECOPY);
X WaitPort(&myproc->pr_MsgPort);
X ReplyMsg(GetMsg(&myproc->pr_MsgPort));
X savedir = Lock("", SHARED_LOCK); /* duplicate current dir */
X if (!savedir) {
X DUnListen(port);
X _exit(1);
X }
X savedir = CurrentDir(savedir); /* CD dup, returns original */
X mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
X for (;;) {
X long dupdir = DupLock(myproc->pr_CurrentDir);
X rmask = Wait(mask);
X if (rmask & SIGBREAKF_CTRL_C) {
X UnLock(CurrentDir(dupdir));
X break;
X }
X while (Chan = DAccept(port)) {
X SGCopy();
X DClose(Chan);
X }
X UnLock(CurrentDir(dupdir));
X }
X UnLock(CurrentDir(savedir)); /* restore original */
X DUnListen(port);
X}
X
Xvoid
XSGCopy()
X{
X short error;
X static HDR Hdr;
X
X error = WriteHeader('H', "Hello, GCopy server V1.30", 0);
X if (error)
X return;
X switch(ReadHeader(&Hdr)) {
X case -1:
X return;
X case 'H':
X break;
X }
X while (!error) {
X switch(ReadHeader(&Hdr)) {
X case 'G':
X error = PutObject(Hdr.Str);
X break;
X case 'E':
X goto done;
X case 'P': /* put-files, not implemented */
X default:
X error = 1;
X break;
X }
X }
Xdone:
X ;
X}
X
Xint
XPutObject(str)
Xchar *str;
X{
X long lock;
X FIB *fib = malloc(sizeof(FIB));
X short error = 0;
X short access = GetEnvVal(DNET_READ);
X short group = GetEnvVal(DNET_GROUP);
X
X mountrequest(0);
X lock = Lock(str, SHARED_LOCK);
X mountrequest(1);
X if (lock == NULL || !Examine(lock, fib)) { /* unable to find it! */
X error = WriteHeader('N', "Unable to find object", 0);
X goto done;
X }
X
X /*
X * Determine Access rights
X *
X * If the file/dir or any parent dir has AC > your_ac, access is
X * denied. If the file/dir and all parent dirs have neither an ACcess
X * or GRoup entry, access is denied. If a group entry is found that
X * matches your group, access is allowed (unless an AC is found > your_ac)
X *
X * If your_ac is >= 9, no access checking of parent directories is
X * done at all. However, access checking of downloaded files will
X * be done, and any AC values > your_ac will be disalloweds.
X */
X
X if (access < 9) { /* must check comment/access */
X short ok = 0;
X long lock2 = DupLock(lock);
X long tmp;
X for (;;) {
X short ac = 0;
X
X while (ac >= 0) { /* check groups */
X short idx = 0;
X ac = ExtractFieldVal(fib->fib_Comment, FS_GROUP, &idx);
X if (ac >= 0 && ac == group) {
X ok = 1;
X break;
X }
X }
X ac = ExtractFieldVal(fib->fib_Comment, FS_ACCESS, NULL);
X if (ac >= 0) { /* valid access field */
X if (ac <= access) { /* access ok */
X ok = 1;
X } else { /* access not ok */
X ok = 0;
X break;
X }
X }
X if (tmp = ParentDir(lock2)) { /* check the par.dir */
X UnLock(lock2);
X lock2 = tmp;
X fib->fib_Comment[0] = 0;
X Examine(lock2, fib);
X continue;
X }
X break;
X }
X UnLock(lock2);
X if (!ok) {
X error = WriteHeader('N', "Access Violation", 0);
X goto done;
X }
X }
X Examine(lock, fib);
X UnLock(lock);
X lock = NULL;
X if (fib->fib_DirEntryType > 0) {
X error = PutDir(str, access);
X } else {
X error = PutFile(str, access);
X }
Xdone:
X if (lock)
X UnLock(lock);
X free(fib);
X return((int)error);
X}
X
Xint
XPutDir(name, access)
Xchar *name;
Xint access;
X{
X long lock = Lock(name, SHARED_LOCK);
X FIB *fib = malloc(sizeof(FIB));
X static HDR Hdr;
X short error = 0;
X short ac;
X
X if (!lock || !Examine(lock, fib)) {
X WriteHeader('N', "Possible Disk Error", 0);
X error = 1;
X goto done;
X }
X
X ac = ExtractFieldVal(fib->fib_Comment, FS_ACCESS, NULL);
X if (ac >= 0 && ac > access) {
X error = WriteHeader('S', fib->fib_FileName, 0);
X goto done;
X }
X
X if (error = WriteHeader('D', fib->fib_FileName, 0))
X goto done;
X switch(ReadHeader(&Hdr)) {
X case 'Y':
X break;
X case 'S':
X goto done;
X case 'N':
X error = 1;
X break;
X default:
X error = 1;
X break;
X }
X if (error)
X goto done;
X while (ExNext(lock, fib)) { /* try to give him the files */
X if (fib->fib_DirEntryType > 0) {
X long oldlock = CurrentDir(lock);
X error = PutDir(fib->fib_FileName, access);
X CurrentDir(oldlock);
X if (error)
X break;
X } else {
X long oldlock = CurrentDir(lock);
X error = PutFile(fib->fib_FileName, access);
X CurrentDir(oldlock);
X if (error)
X break;
X }
X }
X if (!error)
X WriteHeader('E', "Possible Disk Error", 0);
Xdone:
X free(fib);
X if (lock)
X UnLock(lock);
X return((int)error);
X}
X
Xint
XPutFile(name, access)
Xchar *name;
Xint access;
X{
X long lock = Lock(name, SHARED_LOCK);
X long fh = NULL;
X FIB *fib = malloc(sizeof(FIB));
X static HDR Hdr;
X long len;
X short error = 0;
X short ac;
X
X if (!lock || !Examine(lock, fib)) {
X WriteHeader('N', "Possible Disk Error", 0);
X error = 1;
X goto done;
X }
X
X ac = ExtractFieldVal(fib->fib_Comment, FS_ACCESS, NULL);
X if (ac >= 0 && ac > access) {
X error = WriteHeader('S', fib->fib_FileName, 0);
X goto done;
X }
X
X fh = Open(name, 1005);
X if (fh == NULL) /* don't do anything if unable to open it */
X goto done;
X Seek(fh, 0L, 1);
X len = Seek(fh, 0L, 0);
X if (error = WriteHeader('F', fib->fib_FileName, len))
X goto done;
X switch(ReadHeader(&Hdr)) {
X case 'Y':
X Seek(fh, Hdr.Val, -1); /* start pos. */
X len -= Hdr.Val;
X if (len < 0)
X len = 0;
X break;
X case 'S':
X goto done;
X case 'N':
X error = 1;
X break;
X default:
X error = 1;
X break;
X }
X if (error)
X goto done;
X while (len) {
X long n = (len > sizeof(Buf)) ? sizeof(Buf) : len;
X
X if (Read(fh, Buf, n) != n) { /* read failed! */
X error = 10;
X goto done;
X }
X if (DWrite(Chan, Buf, n) != n) {
X error = 10;
X goto done;
X }
X len -= n;
X }
Xdone:
X free(fib);
X if (fh)
X Close(fh);
X if (lock)
X UnLock(lock);
X return((int)error);
X}
X
Xint
XWriteHeader(c, str, len)
Xchar c;
Xchar *str;
Xlong len;
X{
X ubyte sl;
X
X if (str == NULL)
X str = "";
X sl = strlen(str);
X
X if (DWrite(Chan, &c, 1) < 0)
X return(1);
X if (DWrite(Chan, &sl,1) < 0)
X return(1);
X if (DWrite(Chan, str, sl) != sl)
X return(1);
X if (DWrite(Chan, &len, 4) != 4)
X return(1);
X return(0);
X}
X
Xint
XReadHeader(hdr)
XHDR *hdr;
X{
X ubyte sl;
X ubyte cmd;
X
X hdr->Cmd = -1;
X if (DRead(Chan, &cmd, 1) != 1)
X return(-1);
X if (DRead(Chan, &sl, 1) != 1)
X return(-1);
X if (sl >= sizeof(hdr->Str)) {
X return(-1);
X }
X if (DRead(Chan, hdr->Str, sl) != sl)
X return(-1);
X hdr->Str[sl] = 0;
X if (DRead(Chan, &hdr->Val, 4) != 4)
X return(-1);
X hdr->Cmd = cmd;
X return((int)hdr->Cmd);
X}
X
X
END_OF_FILE
if test 8179 -ne `wc -c <'amiga/server/sgcopy.c'`; then
echo shar: \"'amiga/server/sgcopy.c'\" unpacked with wrong size!
fi
# end of 'amiga/server/sgcopy.c'
fi
if test -f 'unix/dnet/subs.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/dnet/subs.c'\"
else
echo shar: Extracting \"'unix/dnet/subs.c'\" \(8247 characters\)
sed "s/^X//" >'unix/dnet/subs.c' <<'END_OF_FILE'
X
X/*
X * SUBS.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * Support subroutines
X *
X */
X
X#include "dnet.h"
X
X/*
X * WRITESTREAM()
X *
X * Queues new SCMD_?? level commands to be sent
X */
X
XWriteStream(sdcmd, buf, len, chan)
Xubyte *buf;
Xuword chan;
X{
X register XIOR *ior = (XIOR *)malloc(sizeof(XIOR));
X
X if (DDebug)
X printf("-writestr cmd %ld (%ld bytes chan %ld)\n", sdcmd, len, chan);
X
X ior->io_Data = (ubyte *)malloc(len);
X ior->io_Length = len;
X ior->io_Actual = 0;
X ior->io_Command = sdcmd;
X ior->io_Error = 0;
X ior->io_Channel = chan;
X ior->io_Pri = (chan > MAXCHAN) ? 126 : Chan[chan].pri;
X bcopy(buf, ior->io_Data, len);
X Enqueue(&TxList, ior);
X /*
X * REMOVED 21 SEPT 1988
X * do_wupdate();
X */
X}
X
X/*
X * ALLOC_CHANNEL()
X *
X * Allocate a free channel. Used in SCMD_OPEN and SCMD_ACKCMD
X */
X
Xalloc_channel()
X{
X static ulong ran = 13;
X register uword i;
X
X ran = ((ran * 13) + 1) ^ (ran >> 9) + time(0);
X for (i = ran % MAXCHAN; i < MAXCHAN; ++i) {
X if (Chan[i].state == 0)
X return(i);
X }
X for (i = ran % MAXCHAN; i < MAXCHAN; --i) {
X if (Chan[i].state == 0)
X return(i);
X }
X return(-1);
X}
X
X/*
X * Remove all nodes with the given channel ID.
X */
X
XClearChan(list, chan, all)
XLIST *list;
Xuword chan;
X{
X register XIOR *io, *in;
X
X for (io = (XIOR *)list->lh_Head; io != (XIOR *)&list->lh_Tail; io = in) {
X in = (XIOR *)io->io_Node.ln_Succ;
X if (io->io_Channel == chan) {
X if (all || io->io_Command == SCMD_DATA) {
X io->io_Node.ln_Succ->ln_Pred = io->io_Node.ln_Pred;
X io->io_Node.ln_Pred->ln_Succ = io->io_Node.ln_Succ;
X free(io->io_Data);
X free(io);
X }
X }
X }
X}
X
X/*
X * Queue a packet into a prioritized list. FIFO is retained for packets
X * of the same priority. This implements one level of channel priorities,
X * before the packets actually get queued to the network. Since up to
X * 4 packets might be queued (200 * 4 = 800 bytes of data or 4 seconds @
X * 2400 baud), a second level of prioritization will also reduce the
X * physical packet size when two channels at relatively large differing
X * priorities are in use.
X *
X * These and other list routines compatible with Amiga list routines.
X */
X
XEnqueue(list, ior)
XLIST *list;
XXIOR *ior;
X{
X register XIOR *io;
X char pri = ior->io_Pri;
X
X io = (XIOR *)list->lh_Head;
X while (io != (XIOR *)&list->lh_Tail) {
X if (pri > io->io_Pri)
X break;
X io = (XIOR *)io->io_Node.ln_Succ;
X }
X ior->io_Node.ln_Succ = (NODE *)io;
X ior->io_Node.ln_Pred = io->io_Node.ln_Pred;
X ior->io_Node.ln_Succ->ln_Pred = (NODE *)ior;
X ior->io_Node.ln_Pred->ln_Succ = (NODE *)ior;
X}
X
XAddTail(list, node)
XLIST *list;
XNODE *node;
X{
X node->ln_Succ = (NODE *)&list->lh_Tail;
X node->ln_Pred = list->lh_TailPred;
X node->ln_Succ->ln_Pred = node;
X node->ln_Pred->ln_Succ = node;
X}
X
XAddHead(list, node)
XLIST *list;
XNODE *node;
X{
X node->ln_Succ = list->lh_Head;
X node->ln_Pred = (NODE *)list;
X node->ln_Succ->ln_Pred = node;
X node->ln_Pred->ln_Succ = node;
X}
X
Xubyte *
XRemHead(list)
XLIST *list;
X{
X NODE *node;
X
X node = list->lh_Head;
X if (node->ln_Succ == NULL)
X return(NULL);
X node->ln_Succ->ln_Pred = node->ln_Pred;
X node->ln_Pred->ln_Succ = node->ln_Succ;
X return((ubyte *)node);
X}
X
XNewList(list)
XLIST *list;
X{
X list->lh_Head = (NODE *)&list->lh_Tail;
X list->lh_Tail = NULL;
X list->lh_TailPred = (NODE *)&list->lh_Head;
X}
X
XGetNext(node)
XNODE *node;
X{
X register NODE *next = node->ln_Succ;
X if (*(long *)next)
X return((long)next);
X return(NULL);
X}
X
X/*
X * CHKBUF
X *
X * Checksum a buffer. Uses a simple, but supposedly very good
X * scheme.
X */
X
Xchkbuf(buf, bytes)
Xregister ubyte *buf;
Xregister uword bytes;
X{
X register uword i;
X register ubyte c1,c2;
X
X for (i = c1 = c2 = 0; i < bytes; ++i) {
X c1 += buf[i];
X c2 += c1;
X }
X c1 = -(c1 + c2);
X return((c1<<8)|c2);
X}
X
X/*
X * Write timeout signal handler.
X */
X
Xsigwto()
X{
X WTimedout = 1;
X}
X
XTimerOpen()
X{
X static struct sigvec SA = { sigwto, 0, 0 };
X sigvec(SIGALRM, &SA, NULL);
X}
X
XTimerClose()
X{
X signal(SIGALRM, SIG_IGN);
X}
X
XWTimeout(secs)
X{
X static struct itimerval itv;
X struct itimerval ov;
X long mask;
X
X itv.it_value.tv_sec = secs;
X itv.it_value.tv_usec= 0;
X
X mask = sigblock(sigmask(SIGALRM));
X setitimer(ITIMER_REAL, &itv, &ov);
X Wto_act = 1;
X WTimedout = 0;
X sigsetmask(mask);
X if (DDebug)
X fprintf(stderr, "WTimeout set\n");
X}
X
Xdneterror(str)
Xchar *str;
X{
X extern int errno;
X register short i;
X int er = errno;
X
X NetClose();
X TimerClose();
X if (str)
X fprintf(stderr, "%s %d\n", str, er);
X else
X fprintf(stderr, "-end-\n");
X exit(1);
X}
X
X/*
X * setenv(name, str). name must be of the form "NAME="
X */
X
Xsetenv(name, str)
Xchar *name;
Xchar *str;
X{
X extern char **environ;
X static char **elist;
X static int elen;
X char *ptr;
X int i, len;
X
X len = strlen(name);
X if (elist == NULL) {
X for (i = 0; environ[i]; ++i);
X elist = (char **)malloc((i+3)*sizeof(char *));
X elen = i + 3;
X bcopy(environ, elist, i*sizeof(char *));
X environ = elist;
X }
X for (i = 0; elist[i]; ++i) {
X if (strncmp(elist[i], name, len) == 0)
X break;
X }
X if (i == elen) {
X elen += 4;
X elist = environ = (char **)realloc(elist, elen*sizeof(char *));
X }
X ptr = (char *)malloc(len + strlen(str) + 1);
X sprintf(ptr, "%s%s", name, str);
X if (elist[i]) {
X elist[i] = ptr;
X } else {
X elist[i] = ptr;
X elist[i+1] = NULL;
X elen = i + 1;
X }
X}
X
Xvoid
Xstartserver(port)
Xuword port;
X{
X char dir[MAXPATHLEN];
X struct passwd pw_info;
X FILE *fi;
X
X if (!port)
X return;
X if (getenv("DNETDIR")) {
X strcpy(dir, getenv("DNETDIR"));
X strcat(dir, "dnet.servers");
X if (fi = fopen(dir, "r")) {
X if (scan_for_server(fi, port))
X return;
X }
X }
X pw_info = *getpwuid(getuid());
X strcpy(dir, pw_info.pw_dir);
X strcat(dir, "/.dnet/dnet.servers");
X if (fi = fopen(dir, "r")) {
X if (scan_for_server(fi, port))
X return;
X }
X /*
X * LAST TRY
X */
X if (fi = fopen(LASTTRYDNETSERVERS, "r")) {
X if (scan_for_server(fi, port))
X return;
X }
X fprintf(stderr, "Unable to find one of (1) dnet.servers or (2) server\n");
X fprintf(stderr, "entry for port %d\n", port);
X fflush(stderr);
X return;
X}
X
Xscan_for_server(fi, port)
XFILE *fi;
Xshort port;
X{
X char buf[256];
X char path[MAXPATHLEN];
X char cdir[MAXPATHLEN];
X long portno;
X short found = 0;
X void checktilda();
X
X while (fgets(buf, 256, fi)) {
X if (sscanf(buf, "%ld %s %s", &portno, path, cdir) == 3) {
X checktilda(path);
X checktilda(cdir);
X if (portno == port) {
X if (!fork()) {
X int i;
X fclose(fi);
X setuid(getuid());
X signal(SIGHUP, SIG_DFL);
X signal(SIGINT, SIG_DFL);
X signal(SIGQUIT, SIG_DFL);
X signal(SIGTERM, SIG_DFL);
X signal(SIGCHLD, SIG_DFL);
X signal(SIGTSTP, SIG_IGN);
X ioctl(open("/dev/tty", 2), TIOCNOTTY, NULL);
X i = open("/dev/null", O_RDWR, 0);
X dup2(i, 0);
X dup2(i, 1);
X for (i = 3; i < 256; ++i)
X close(i);
X sprintf(buf, "server.%ld.%ld", port, getuid());
X execl(path, buf, cdir, NULL);
X fprintf(stderr, "Unable to exec server: %s\n", path);
X fflush(stderr);
X _exit(1);
X }
X sleep(4); /* is a hack */
X found = 1;
X break;
X }
X }
X }
X fclose(fi);
X return(found);
X}
X
Xvoid
Xchecktilda(buf)
Xchar *buf;
X{
X if (buf[0] == '~') {
X short bindex = 1;
X short pathlen;
X struct passwd pw_info, *pw;
X
X pw_info.pw_dir = getenv("HOME");
X if (buf[1] && buf[1] != '/') {
X char username[128];
X while (buf[bindex] && buf[bindex] != '/')
X ++bindex;
X bcopy(buf+1, username, bindex-1);
X username[bindex-1] = 0;
X if (pw = getpwnam(username)) {
X pw_info = *pw;
X } else {
X fprintf(stderr, "Unable to find password entry for %s\n",
X username
X );
X fprintf(stderr, "passing /tmp as dir for server");
X fflush(stderr);
X pw_info.pw_dir = "/tmp";
X }
X }
X
X /*
X * ~[username]<rest of path> -> <basedir><rest of path>
X */
X
X pathlen = strlen(pw_info.pw_dir);
X bcopy(buf + bindex, buf + pathlen, strlen(buf + bindex) + 1);
X bcopy(pw_info.pw_dir, buf, pathlen);
X }
X fflush(stderr);
X}
X
END_OF_FILE
if test 8247 -ne `wc -c <'unix/dnet/subs.c'`; then
echo shar: \"'unix/dnet/subs.c'\" unpacked with wrong size!
fi
# end of 'unix/dnet/subs.c'
fi
echo shar: End of archive 5 \(of 8\).
cp /dev/null ark5isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 8 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.